#ifndef __COMMAND_BASE_H__
#define __COMMAND_BASE_H__
#include "common.h"
#include <string>
#include <vector>

BEG_DEF_NAMESPACE_SMTPUTILS

template< typename T, typename P=std::string, typename O=std::string, typename I=const std::string& >
class CommandBase{
public:
	typedef std::vector<P> ParmContainer;
	CommandBase();
	virtual O BuildOutput() const =0;
	virtual void PushParm( const P& parm );
	virtual void SetCmdCode( const T& cmdCode );
	virtual const T& GetCmdCode() const;
	virtual const ParmContainer& GetParmsVector() const;
	virtual ParmContainer& GetParmsVector();
	virtual const P& GetCmdParm(uint32_t n) const;
	virtual P& GetCmdParm(uint32_t n);
	virtual uint32_t GetParmsSize() const;
	virtual bool GetParmsEmpty() const;
	virtual int32_t Parse( I input );
	virtual void ClearParms();
protected:
	T mCmdCode;
	ParmContainer mCmdParms;
};

template< typename T, typename P, typename O, typename I>
CommandBase<T,P,O,I>::CommandBase(){
}

template< typename T, typename P, typename O, typename I>
void CommandBase<T,P,O,I>::PushParm( const P& parm ){
	mCmdParms.push_back(parm);
	return;
}

template< typename T, typename P, typename O, typename I>
void CommandBase<T,P,O,I>::SetCmdCode( const T& cmdCode ){
	mCmdCode = cmdCode;
	return;
}

template< typename T, typename P, typename O, typename I>
const T& CommandBase<T,P,O,I>::GetCmdCode() const{
	return mCmdCode;
}

template< typename T, typename P, typename O, typename I>
const typename CommandBase<T,P,O,I>::ParmContainer& 
CommandBase<T,P,O,I>::GetParmsVector() const{
	return mCmdParms;
}

template< typename T, typename P, typename O, typename I>
typename CommandBase<T,P,O,I>::ParmContainer& 
CommandBase<T,P,O,I>::GetParmsVector(){
	return mCmdParms;
}

template< typename T, typename P, typename O, typename I>
P& CommandBase<T,P,O,I>::GetCmdParm( uint32_t n){
	return mCmdParms[n];
}

template< typename T, typename P, typename O, typename I>
const P& CommandBase<T,P,O,I>::GetCmdParm( uint32_t n) const{
	return mCmdParms[n];
}

template< typename T, typename P, typename O, typename I>
uint32_t CommandBase<T,P,O,I>::GetParmsSize() const{
	return mCmdParms.size();
}

template< typename T, typename P, typename O, typename I>
bool CommandBase<T,P,O,I>::GetParmsEmpty() const{
	return mCmdParms.empty();
}

template< typename T, typename P, typename O, typename I>
int32_t CommandBase<T,P,O,I>::Parse( I input ){
	return 0;
}

template< typename T, typename P, typename O, typename I>
void CommandBase<T,P,O,I>::ClearParms(){
	mCmdParms.clear();
	return;
}

END_DEF_NAMESPACE_SMTPUTILS
#endif

